package com.schoolhelper.exception;

import com.schoolhelper.utils.Result;
import io.jsonwebtoken.ExpiredJwtException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(ExpiredJwtException.class)
    public Result handleExpiredJwtException(ExpiredJwtException e) {
        return Result.error(401, "令牌已过期，请重新登录");
    }

    @ExceptionHandler(Exception.class)
    public Result handleGlobalException(Exception e) {
        return Result.error(500, "服务器内部错误：" + e.getMessage());
    }
}
